import { useQuery } from "react-query";
import { useRequest } from "../utils/request";

/**
 * !获取首页卡片统计/statistic/getSysHomeCardValue
 * @returns
 */
export const useGetSysHomeCardValue = () => {
  const request = useRequest<IHomCardVO[]>();
  return useQuery(["getSysHomeCardValue"], () =>
    request("/statistic/getStatisticOfSjTj", { data: {} })
  );
};
/**
 * !导出所涉及的数据
 * @returns
 */
export const useExportAllOfJoin = () => {
  const request = useRequest<IHomCardVO[]>();
  return useQuery(["exportAllOfJoin"], () =>
    request("/export/exportAllOfJoin", { data: {} })
  );
};
/**
 * !获取首页分类统计
 * @returns
 */
export const useGetTaskStatistic = () => {
  const request = useRequest<IHomTypeVO>();
  return useQuery(["getTaskStatistic"], () =>
    request("/statistic/getTaskStatistic", { data: {} })
  );
};

/**
 * !矛盾纠纷来源统计
 * @returns
 */
export const useGetCardPieVOByBeefSource = () => {
  const request = useRequest<IPieVO[]>();
  return useQuery(["getCardPieVOByBeefSource"], () =>
    request("/statistic/getCardPieVOByBeefSource", { data: {} })
  );
};

/**
 * !矛盾纠纷风险等级统计
 * @returns
 */
export const useGetCardPieVOByRiskLevel = () => {
  const request = useRequest<IPieVO[]>();
  return useQuery(["getCardPieVOByRiskLevel"], () =>
    request("/statistic/getCardPieVOByRiskLevel", { data: {} })
  );
};

/**
 * !矛盾重点人员统计
 * @returns
 */
export const useGetCardPieVOByKeyPersonnel = () => {
  const request = useRequest<IPieVO[]>();
  return useQuery(["getCardPieVOByKeyPersonnel"], () =>
    request("/statistic/getCardPieVOByKeyPersonnel", { data: {} })
  );
};

/**
 * !获取到个人已完成排名
 * @returns
 */
export const useGetStatisticByUserRank = () => {
  const request = useRequest<IUserRank[]>();
  return useQuery(["getStatisticByUserRank"], () =>
    request("/statistic/getStatisticByUserRank", { data: {} })
  );
};
/**
 * !获取到个人已完成排周
 * @returns
 */
export const useGetStatisticByUserRankWeek = () => {
  const request = useRequest<IUserRank[]>();
  return useQuery(["getStatisticByUserRankWeek"], () =>
    request("/statistic/getStatisticByUserRankWeek", { data: {} })
  );
};

/**
 * !获取到个人已完成排名月
 * @returns
 */
export const useGetStatisticByUserRankMonth = () => {
  const request = useRequest<IUserRank[]>();
  return useQuery(["getStatisticByUserRankMonth"], () =>
    request("/statistic/getStatisticByUserRankMonth", { data: {} })
  );
};
/**
 * !近30天的新增数据
 * @returns
 */
export const useGetAddBeefByMonth = () => {
  const request = useRequest<IUserRank[]>();
  return useQuery(["getAddBeefByMonth"], () =>
    request("/statistic/getAddBeefByMonth", { data: {} })
  );
};

/**
 * !单位排名统计
 * @returns
 */
export const useGetUnitBeefRank = () => {
  const request = useRequest<IUserRank[]>();
  return useQuery(["getUnitBeefRank"], () =>
    request("/statistic/getUnitBeefRank", { data: {} })
  );
};

export type IUserRank = {
  value: number;
  name: string;
};

export type IHomCardVO = {
  all: number;
  process: number;
  ratio: number;
  userCount: number;
  count:number;
  percent:number;
};

export type IHomTypeVO = {
  name: string;
  value: number;
  rate: number;
};

export type IPieVO = {
  item: string;
  count: number;
  percent: number;
};
